package org.hawk.gwt.ppc.introspection.impl;

import java.util.List;

import org.hawk.gwt.ppc.introspection.JavaParameterizedGenericTypeScope;
import org.hawk.gwt.ppc.introspection.JavaScope;
import org.hawk.gwt.ppc.introspection.JavaTypeScope;

/**
 * Provides parameterized type scope implementation.
 * @author alex.bereznevatiy@gmail.com
 *
 */
final class JavaParameterizedGenericTypeScopeImpl extends AbstractJavaGenericTypeScope implements JavaParameterizedGenericTypeScope {
	
	private String params;
	private List<JavaTypeScope> typeParams;

	JavaParameterizedGenericTypeScopeImpl(JavaTypeScope raw, JavaScope owner, String params) {
		super(raw, owner);
		this.params = params;
	}

	/*
	 * (non-Javadoc)
	 * @see org.hawk.gwt.ppc.introspection.JavaParameterizedGenericTypeScope#getTypeParameters()
	 */
	public List<JavaTypeScope> getTypeParameters() {
		if (typeParams == null) {
			typeParams = GenericHelper.buildTypeParams(params, (JavaScopeImpl)getOwner());
		}
		return typeParams;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return getName() + params;
	}
}
